package org.eliza.base.basicx.datatypex

import kotlin.math.roundToInt

private fun basic() {

}

private fun isSomething(obj: Any): Int {
    if (obj !is String) {
        // obj ->Any
        return obj.hashCode()
    }
    if (obj is String) {
        // 做过类型判断以后，obj会被系统自动转换为String类型
        // obj ->String
        return obj.length
    }
    // obj ->Int
    if (obj is Int && obj > 20) { //
        return obj.length
    }
    return 0
}

private fun number() {
    println("====number=====")
    val num01: Int = "867".toInt()
//    val num02: Int = "86.7".toInt()报错
    val num02: Int? = "86.7".toIntOrNull()//返回null
    println(num02)
    """Double --->Int"""
    println(11.6.toInt())//砍头
    println(11.6.roundToInt())//四舍五入
    val format = "%.2f".format(2.4323)
    println(format)//2.43
}

private  fun main() {
    println(isSomething("aa"))
}